import smtplib
from email.mime.text import MIMEText
from email.header import Header
host_server='smtp.qq.com'
sender='531786847@qq.com'
code='fxqvalyklodxcagb'
user='viscaria@webmail.hzau.edu.cn'
mail_title='文本邮件测试'
mail_content='这是一段纯文本'
smtp=smtplib.SMTP(host_server)
smtp.login(sender,code)
msg=MIMEText(mail_content,'plain','utf-8')
msg['Subject']=Header(mail_title,'utf-8')
msg['From']=Header(sender,'utf-8')
msg['To']=Header(user,'utf-8')
smtp.sendmail(sender,user,msg.as_string())
smtp.quit()
